package com.lzy.product.service.impl;

import com.lzy.framework.core.utils.DozerUtils;
import com.lzy.product.dao.AgentProtocolSystemMapperExt;
import com.lzy.product.dtos.agent.AgentProtocolSystemDto;
import com.lzy.product.entity.AgentProtocolSystem;
import com.lzy.product.service.AgentProtocolSystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class AgentProtocolSystemServiceImpl implements AgentProtocolSystemService {

    @Autowired
    private AgentProtocolSystemMapperExt agentProtocolSystemMapperExt;

    @Override
    public Long insert(AgentProtocolSystemDto dto) {
        AgentProtocolSystem agentProtocolSystem = DozerUtils.map(dto, AgentProtocolSystem.class);
        return agentProtocolSystemMapperExt.insertSelective(agentProtocolSystem) > 0 ? agentProtocolSystem.getId() : 0;
    }

    @Override
    public Boolean update(AgentProtocolSystemDto dto) {
        return agentProtocolSystemMapperExt.updateByPrimaryKeySelective(DozerUtils.map(dto, AgentProtocolSystem.class)) > 0;
    }

    @Override
    public Boolean delete(Long id) {
        return null;
    }

    @Override
    public Boolean remove(Long id) {
        return null;
    }

    @Override
    public AgentProtocolSystemDto findById(Long id) {
        return DozerUtils.map(agentProtocolSystemMapperExt.selectByPrimaryKey(id), AgentProtocolSystemDto.class);
    }

    @Override
    public List<AgentProtocolSystemDto> query(AgentProtocolSystemDto dto) {
        return null;
    }

    @Override
    public List<AgentProtocolSystemDto> selectByProtocolId(Long protocolId) {
        return agentProtocolSystemMapperExt.selectByProtocolId(protocolId);
    }

    @Override
    public Boolean deleteByProtocolId(Long protocolId) {
        return agentProtocolSystemMapperExt.deleteByProtocolId(protocolId);
    }
}
